public class DeadThread extends Thread{

    private final String object1;

    private final String object2;

    public DeadThread(String name,String object1, String object2) {
        super(name);
        this.object1 = object1;
        this.object2 = object2;
    }


    @Override
    public void run() {

        try {
            while (true){
                synchronized (object1){
                    System.out.println(Thread.currentThread().getName()+"锁住变量"+object1);
                    Thread.sleep(1000);

                    synchronized (object2){
                        System.out.println(Thread.currentThread().getName()+"锁住变量"+object2);

                    }
                }
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
